package com.qlzb.taskmanagement.pojo;

/**
 * Created with IntelliJ IDEA.
 *
 * @ClassName outputWrapper
 * @Description  TODO   预定结果信息，统一数据返回格式
 * @Authr 袁聪
 * @Date 2018/6/1 16:05
 * @Version v2.0
 */
public class AppointOutputWrapper {

    // 是否成功
    private boolean result;
    // 状态码
    private String statusCode;
    // 返回信息
    private String message;
    // 返回数据
    private Object data;



    /**
     * 自定义返回结果
     * 建议使用统一的返回结果，特殊情况可以使用此方法
     * @param success
     * @param code
     * @param message
     * @param data
     * @return
     */
    public static AppointOutputWrapper markCustom(boolean success, String code, String message, Object data){
        AppointOutputWrapper outputWrapper = new AppointOutputWrapper();
        outputWrapper.setResult(success);
        outputWrapper.setStatusCode(code);
        outputWrapper.setMessage(message);
        outputWrapper.setData(data);
        return outputWrapper;
    }







//---------------------------- 数据库 增删改查 start (Service层返回结果) --------------------------------------



    /**
     * 添加数据成功
     * @return
     */
    public static AppointOutputWrapper markInsertSuccess(Object o){
        AppointOutputWrapper outputWrapper = new AppointOutputWrapper();
        outputWrapper.setResult(true);
        outputWrapper.setStatusCode(ReturnCode.ADD_SUCCESS.getCode());
        outputWrapper.setMessage(ReturnCode.ADD_SUCCESS.getMessage());
        outputWrapper.setData(o);
        return outputWrapper;
    }

    /**
     * 添加数据失败
     * @return
     */
    public static AppointOutputWrapper markInsertError(){
        AppointOutputWrapper outputWrapper = new AppointOutputWrapper();
        outputWrapper.setResult(false);
        outputWrapper.setStatusCode(ReturnCode.ADD_ERROR.getCode());
        outputWrapper.setMessage(ReturnCode.ADD_ERROR.getMessage());
        outputWrapper.setData(null);
        return outputWrapper;
    }






//---------------------------- 数据库 增删改查 end --------------------------------------

    public boolean isResult() {
        return result;
    }

    public void setResult(boolean result) {
        this.result = result;
    }

    public String getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(String statusCode) {
        this.statusCode = statusCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "AppointOutputWrapper{" +
                "result=" + result +
                ", statusCode='" + statusCode + '\'' +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
